<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        var arr = [];
        var bigObj = {};
        var obj = (function fn(){
           var val = ''; 
           return  Object.defineProperties(bigObj,{
                name:{
                    get(){
                        // console.log('执行了');
                        
                        return val || 'abc';
                    },
                    set(v){
                        // console.log('set执行了');

                        arr.push(v);

                        val = v;
                    }
                }
            })
        })();
        

        obj.name = '老王';
        obj.name = '小李';
        obj.name = '小高';
        obj.name = '小金';

        console.log(obj.name);
        console.log(arr);

    </script>
</body>
</html>